<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class DeviceAlarmMessage extends Model
{
    protected $table = 'device_alarm_message';

    protected $fillable = [
    	'device_ip',
    	'device_desc',
    	'location',
    	'device_abnormal_information',
    	'update_time',
    	'handling_situation',
    	'remark'
    ];

    const HANDLING_SITUATION_ZERO = 0;

    const HANDLING_SITUATION_ONE = 1;

    public static $HANDLING_SITUATION = [
    	self::HANDLING_SITUATION_ZERO => '已处理',
    	self::HANDLING_SITUATION_ONE => '未处理'
    ];

    protected $appends = [
    	'handling_situation_desc'
    ];

    public function getHandlingSituationDescAttribute(){
    	if(array_key_exists('handling_situation',$this->attributes) && $this->attributes['handling_situation'] != null){
            return $this->attributes['handling_situation_desc'] = self::$HANDLING_SITUATION[$this->attributes['handling_situation']];
        }
    }
}
